// IoCpp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <assert.h>
#include "nef.h"
#include <sstream>

//class B
//{
//	friend nef_traits<B>;
//public:
//	
//
//private:
//	std::vector<Base::Ptr> _bases;
//};
//
//template<>
//struct nef_traits<B>
//{
//	typedef nef_export<B> export0;
//	typedef nef_import_many<B, Base, &B::_bases> import0;
//};
//
//
//class IValGetterA
//{
//public:
//	virtual ~IValGetterA() {}
//
//	virtual std::string GetAVal() = 0;
//};
//
//class IValGetterB
//{
//public:
//	virtual ~IValGetterB() {}
//
//	virtual std::string GetBVal() = 0;
//};
//
//class ValGetter
//	: public virtual IValGetterA,
//	  public virtual IValGetterB
//{
//public:
//	ValGetter()
//	{
//		static int COUNTER = 0;
//
//		int val = COUNTER++;
//		std::stringstream ss;
//		ss << val;
//
//		_root = ss.str();
//	}
//
//	virtual std::string GetAVal() 
//	{
//		return _root + "A";
//	}
//
//	virtual std::string GetBVal() 
//	{
//		return _root + "B";
//	}
//
//private:
//	std::string _root;
//};
//
//// If this implementation is non-buggy, either import will return the same instance
//nef_export<ValGetter, IValGetterA> exportValA;
//nef_export<ValGetter, IValGetterB> exportValB;
//
//
//
//int _tmain(int argc, _TCHAR* argv[])
//{
//	auto cat = catalog::Create();
//
//	// Manually create a new export, using a shared creation policy, initialized to value 42,
//	// and using the contract STUFF_EXPORT
//	cat.AddExport(shared::Scope<int>(std::make_shared<int>(42)), THE_MEANING_OF_LIFE);
//	
//	// Ask the catalog for a B.
//	// Note that we didn't have to explicitly register this type, nor do we have to register A, which
//	// B has a dependency on. If the registration is non-polymorphic, the container will automatically detect
//	// B's exports and imports, which automatically resolves A's exports since it is in the dependency chain
//	auto bExport = cat.GetExportedValue<B>();
//
//
//	// Since the export for IValGetterA and the export for IValGetterB are both shared,
//	// and implemented by the same type, we expect them to share the same instance.
//	auto valA = cat.GetExportedValue<IValGetterA>();
//	auto valB = cat.GetExportedValue<IValGetterB>();
//
//	std::string a = valA->GetAVal();
//	std::string b = valB->GetBVal();
//
//	assert(a[0] == b[0]);
//
//	// This part demo's how we can actually get the factory implementation for a type.
//	// This allows client code to dynamically create new instances
//	auto valAFactory = cat.GetExportFactory<IValGetterA>();
//
//	auto aa = valAFactory->create();
//	auto aa2 = valAFactory->create();
//
//	return 0;
//}

